extends Control

@onready var label : Label = $Label

var is_full_info : bool = true

# Called when the node enters the scene tree for the first time.
func _ready():
	fill_label()
	ENV.current_catalog_path_changed.connect(fill_label)

func _fully_info_mode(is_on : bool = true):
	is_full_info = is_on
	fill_label()
	ENV.current_catalog_path_changed.connect(fill_label)

func fill_label():
	if is_full_info and not ENV.current_catalog_data.is_empty():
		var cat_info : Dictionary = ENV.current_catalog_data
		label.text = str("КАТ: ", cat_info["alias"], 
						"|ДН: ", get_dec_num(),
						"|РСЖ: ", ENV.current_catalog_path)
	elif not ENV.current_catalog_data.is_empty():
		var cat_info : Dictionary = ENV.current_catalog_data
		label.text = str("КАТ: ", cat_info["alias"], "|ДН: ", get_dec_num())
	else:
		label.text = str("ТЕКУЩИЙ КАТАЛОГ: ", ENV.current_catalog_path
			 if not ENV.current_catalog_path.is_empty() else "НЕ ВЫБРАН" )

func get_dec_num()->String:
	var num : String
	var int_num : int = ENV.current_catalog_data["decimal_id"]
	
	if int_num < 10:
		num = str("0", int_num)
	else:
		num = str(int_num)
	return num
